package com.sun.hunk.hibernate.domain.impl;

import com.sun.hunk.hibernate.domain.Role;
import com.sun.hunk.hibernate.domain.RoleLink;
import com.sun.hunk.hibernate.domain.UserRole;
import java.util.Date;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author sunil
 */
@Entity
@Table(name = "role")
public class RoleImpl implements Role {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "description")
    private String description;
    @Column(name = "created_on")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdOn;
    @OneToMany(mappedBy = "roleId",targetEntity=RoleLinkImpl.class)
    private Set<RoleLink> roleLinkSet;
    @OneToMany(mappedBy = "roleId",targetEntity=UserRoleImpl.class)
    private Set<UserRole> userRoleSet;

    public RoleImpl() {
    }

    public RoleImpl(Long id) {
        this.id = id;
    }

    public RoleImpl(String description) {
        this.description = description;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public Set<RoleLink> getRoleLinkSet() {
        return roleLinkSet;
    }

    public void setRoleLinkSet(Set<RoleLink> roleLinkSet) {
        this.roleLinkSet = roleLinkSet;
    }

    public Set<UserRole> getUserRoleSet() {
        return userRoleSet;
    }

    public void setUserRoleSet(Set<UserRole> userRoleSet) {
        this.userRoleSet = userRoleSet;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final RoleImpl other = (RoleImpl) obj;
        if ((this.description == null) ? (other.description != null) : !this.description.equals(other.description)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 53 * hash + (this.description != null ? this.description.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "com.cong.logiware.hibernate.domain.Role[id=" + id + "]";
    }

}
